package com.obixlabs.security.credentialsstore.services;

import java.rmi.RemoteException;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

import com.obixlabs.security.credentialsstore.exception.EntryAlreadyExistsException;
import com.obixlabs.security.credentialsstore.exception.EntryNotFoundException;
import com.obixlabs.security.credentialsstore.model.BaseUser;
import com.obixlabs.security.credentialsstore.model.User;

@WebService (	name=UserManagementService.SERVICE_NAME, 
				targetNamespace=SecurityServiceConstants.SECURITY_SERVICES_TARGET_NAMESPACE)
public interface UserManagementService extends SecurityService
{
	String SERVICE_NAME = "UserManagementService";
	
	@WebMethod(operationName="authenticateUser")
	BaseUser authenticateUser(	@WebParam String username,
								@WebParam String password)
								throws RemoteException;
	
	@WebMethod(operationName="authenticateHumanUser")
	User authenticateHumanUser(	@WebParam String username,
								@WebParam String password)
								throws RemoteException;

	<T extends BaseUser> T refreshUserDetails(T user)
							throws RemoteException;
	
	@WebMethod(operationName="findByEmailAddress")
	BaseUser findByEmailAddress(@WebParam String emailAddress)
								throws RemoteException;

	@WebMethod(operationName="createUser")
	void createUser(@WebParam BaseUser user) 
					throws 	RemoteException, EntryAlreadyExistsException;
	
	@WebMethod(operationName="updateUser")
	BaseUser updateUser(@WebParam BaseUser user) 
						throws 	RemoteException, EntryNotFoundException;	
	
	@WebMethod(operationName="deleteUser")
	void deleteUser(@WebParam BaseUser user)
					throws RemoteException;
	
	@WebMethod(operationName="isUserIdInUse")
	boolean isUserIdInUse(@WebParam String userId)
						  throws RemoteException;
}